package init.utils;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;


public class ExecuteUtils {
	private Connection conn = null;
	
	
	private ExecuteUtils() throws SQLException{
		conn = ConnectionUtils.getConnection();
	}
	
	public Connection getConnection(){
		return conn;
	}
	
	public static ExecuteUtils getExecuter() throws SQLException{
		return new ExecuteUtils();
	}

	public void execute(String sql) throws SQLException{
		Statement s = null; 
		try{
			s = conn.createStatement();
			if(ConfigUtils.showSql()){
				LogUtils.logging(ExecuteUtils.class, sql);
			}
			s.execute(sql);
		} finally{			
			s.close();
		}
	}
	
	public void release(){
		conn = null;
		try {
			ConnectionUtils.release();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
